//
//  SettingsView.swift
//  redbox
//
//  Created by ma c on 2025/9/11.
//

import SwiftUI

struct SettingsView: View {
    @AppStorage("autoClaimEnabled") private var autoClaimEnabled = true
    @AppStorage("notificationsEnabled") private var notificationsEnabled = true
    @AppStorage("clearCookiesOnExit") private var clearCookiesOnExit = false
    
    var body: some View {
        NavigationView {
            List {
                Section(header: Text("功能设置")) {
                    Toggle("自动领取", isOn: $autoClaimEnabled)
                    
                    Toggle("消息通知", isOn: $notificationsEnabled)
                    
                    Toggle("退出时清除Cookie", isOn: $clearCookiesOnExit)
                }
                
                Section(header: Text("关于")) {
                    HStack {
                        Text("版本")
                        Spacer()
                        Text("1.0.0")
                            .foregroundColor(.secondary)
                    }
                    
                    NavigationLink(destination: AboutView()) {
                        Text("关于应用")
                    }
                }
                
                Section {
                    Button("清除所有数据", role: .destructive) {
                        // TODO: 实现清除数据功能
                    }
                }
            }
            .navigationTitle("设置")
        }
    }
}

struct AboutView: View {
    var body: some View {
        List {
            Section(header: Text("应用信息")) {
                HStack {
                    Text("名称")
                    Spacer()
                    Text("DNF福利盒子")
                        .foregroundColor(.secondary)
                }
                
                HStack {
                    Text("版本")
                    Spacer()
                    Text("1.0.0")
                        .foregroundColor(.secondary)
                }
                
                HStack {
                    Text("开发者")
                    Spacer()
                    Text("ma c")
                        .foregroundColor(.secondary)
                }
            }
            
            Section(header: Text("功能特性")) {
                Text("• 多账号盒子管理")
                Text("• 自动福利领取")
                Text("• 登录状态维持")
                Text("• 批量操作支持")
            }
            
            Section(header: Text("技术支持")) {
                Link("反馈问题", destination: URL(string: "mailto:support@example.com")!)
                Link("检查更新", destination: URL(string: "https://example.com/update")!)
            }
        }
        .navigationTitle("关于应用")
    }
}

#Preview {
    SettingsView()
}